
from celery_package.tasks import jump

# 直接执行函数
# jump(10, 20)

# 添加celery立即任务
# jump.delay(10, 20)

# 添加延迟任务
from datetime import datetime, timedelta
def eta_second(second):
    ctime = datetime.now()
    utc_ctime = datetime.utcfromtimestamp(ctime.timestamp())
    time_delay = timedelta(seconds=second)
    return utc_ctime + time_delay
def eta_days(days):
    ctime = datetime.now()
    utc_ctime = datetime.utcfromtimestamp(ctime.timestamp())
    time_delay = timedelta(days=days)
    return utc_ctime + time_delay

# args是jump任务需要的参数，没有就设置为空()
# eta是该任务执行的UTC格式的时间
# apply_async就是添加延迟任务
jump.apply_async(args=(200, 50), eta=eta_second(10))


